#include <cstdint>
#include <iostream>
#include <istream>
#include <vector>
#include <climits>
#include <tuple>

using namespace std;
using ll = int64_t;

int main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, m, k, s;
    cin >> n >> m >> k >> s;
    vector<string> raw(n);
    for (ll i = 0; i < n; i++) {
        cin >> raw[i];
    }

    vector<tuple<ll, ll, ll, ll, char>> ops;
    for (ll i = 0; i < k; i++) {
        ll x1, y1, x2, y2;
        char c;
        cin >> x1 >> y1 >> x2 >> y2 >> c;
        x1--; y1--; x2--; y2--;
        ops.emplace_back(x1, y1, x2, y2, c);
    }

    vector<vector<string>> cps;
    for (ll i = 0; i < k; i++) {
        vector<string> cp = raw;
        ll x1 = get<0>(ops[i]);
        ll y1 = get<1>(ops[i]);
        ll x2 = get<2>(ops[i]);
        ll y2 = get<3>(ops[i]);
        char c = get<4>(ops[i]);
        for (ll x = x1; x <= x2; x++) {
            for (ll y = y1; y <= y2; y++) {
                cp[x][y] = c;
            }
        }
        cps.push_back(cp);
    }

    vector<vector<ll>> dist(k, vector<ll>(k, 0));
    for (ll i = 0; i < k; i++) {
        for (ll j = i + 1; j < k; j++) {
            ll d = 0;
            for (ll x = 0; x < n; x++) {
                for (ll y = 0; y < m; y++) {
                    d += abs(cps[i][x][y] - cps[j][x][y]);
                }
            }
            dist[i][j] = d;
            dist[j][i] = d;
        }
    }

    vector<ll> g(k, 0);
    for (ll i = 0; i < k; i++) {
        for (ll j = 0; j < k; j++) {
            if (i != j) {
                g[i] += dist[i][j];
            }
        }
    }

    ll ming = INT_MAX;
    ll minidx = -1;
    for (ll i = 0; i < k; i++) {
        if (g[i] < ming) {
            ming = g[i];
            minidx = i;
        }
    }

    cout << ming << " " << minidx + 1 << endl;
    return 0;
}